package com.woniuxy.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Utils {

    public static Connection getConnection() throws IOException, TimeoutException {
        //创建连接工厂
        ConnectionFactory connectionFactory=new ConnectionFactory();
        //设置连接工厂信息
        connectionFactory.setHost("127.0.0.1");//可以不设置 默认就是localhost
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("guest");
        connectionFactory.setPassword("guest");
        //获取连接对象
        Connection connection = connectionFactory.newConnection();
        return  connection;
    }
}
